#ifndef COUNTEXCEPTIONCHECKER_H
#define COUNTEXCEPTIONCHECKER_H

#include <deque>
#include <map>
#include <stdint.h>


class CountExceptionChecker
{
public:
    static const int DURATION = 2000;

    typedef std::pair<int64_t, int>     TimedCount;

public:
    CountExceptionChecker();

    CountExceptionChecker& setThreshold(int maxChange, int duration);

    bool check(int count, TimedCount& dif);

    void clear();

protected:

    typedef std::deque< TimedCount>     TimedCountQueue;

    int64_t getTime();

    void clearExpired(int64_t ts);

private:
    int m_maxChange;
    int m_duration;

    TimedCountQueue m_timedCountQueue;

};

#endif // COUNTEXCEPTIONCHECKER_H
